const { Duplex } = require('stream')

class MyDuplex extends Duplex{
  constructor(source){
    super()
    this.source = source
  }
  _read(){
    let data = this.source.shift() || null
    this.push(data)
  }
  _write(chunk,en,next){
    process.stdout.write(chunk.toString()+'<----')
    process.nextTick(next)
  }
}

let source = ['aa', 'bb', 'cc']
let myDp = new MyDuplex(source)
// myDp.on('data', (chunk)=>{
//   console.log(chunk.toString())
// })
// // aa
// // bb
// // cc
myDp.write('ddeeff',()=>{
  console.log(111)
})
// ddeeff<----111
